package leetcode_周赛._2021._202112._19;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/12/19 10:39
 */
public class _5957 {
    public static void main(String[] args) {
        System.out.println(new _5957().addSpaces("LeetcodeHelpsMeLearn", new int[]{8, 13, 15}));
    }

    public String addSpaces(String s, int[] spaces) {
        int len = s.length();
        char[] chars = new char[len + spaces.length];
        for (int i = 0; i < spaces.length; i++) chars[spaces[i] + i] = ' ';
        int idx = 0;
        for (int i = 0; i < len; i++) {
            while (chars[idx] == ' ') ++idx;
            chars[idx] = s.charAt(i);
            ++idx;
        }
        return new String(chars);
    }

}
